package com.whut.controller;

import com.whut.model.Contracttaskaccept;
import com.whut.service.ZhouqiInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.json.JsonObject;
import java.util.Map;

@Controller
@RequestMapping("/ZhouqiInfo")
public class ZhouqiInfoController {
    @Resource
    private ZhouqiInfoService zhouqiInfoService;

    @ResponseBody
    @PostMapping("/getTaskInfo")
    public Object getTaskInfo(String searchParams,int pageNum,int pageSize){
        if(searchParams.equals("")||searchParams == null){
            return zhouqiInfoService.getTaskInfoByPage(pageNum,pageSize);
        }else{
            return zhouqiInfoService.getTaskInfoSearchParams(searchParams);
        }
    }

    @ResponseBody
    @PostMapping("/getGroupHead")
    public Object getGroupHead(Integer groupId){
        System.out.println("groupId: "+groupId);
        return zhouqiInfoService.getGroupHead(groupId);
    }

    @ResponseBody
    @PostMapping("/getGroupMemb")
    public Object getGroupMemb(Integer groupId){
        return zhouqiInfoService.getGroupMemb(groupId);
    }

    @ResponseBody
    @PostMapping("/getContractCheckTaskInfo")
    public Object getContractCheckTaskInfo(Integer taskId,int curPage,int pageSize){
        return zhouqiInfoService.getContractCheckTaskInfo(taskId,curPage,pageSize);
    }

    @ResponseBody
    @PostMapping("/getGroupInfo")
    public Object getGroupInfo(String params){
        return zhouqiInfoService.getGroupInfo();
    }

    @ResponseBody
    @PostMapping("/addTaskInfo")
    public Object addTaskInfo(String info,String stage1,String stage2){
        return zhouqiInfoService.addTaskInfo(info,stage1,stage2);
    }

    @ResponseBody
    @PostMapping("/deleteTask")
    public Object deleteTask(int taskId){
        return zhouqiInfoService.deleteTask(taskId);
    }

    @ResponseBody
    @PostMapping("/insertProjectToTask")
    public Object insertProjectToTask(String isFinish,String multipleSelection,String creator,String createTime,int groupId,int taskId,String checkName){
        return zhouqiInfoService.insertProjectToTask(isFinish,creator,createTime,groupId,multipleSelection,taskId,checkName);
    }

    @ResponseBody
    @PostMapping("/editCheckTask")
    public Object editCheckTask(Integer taskId,String reserve1){
        return zhouqiInfoService.editCheckTaskById(taskId,reserve1);
    }

    @ResponseBody
    @PostMapping("/getCheckTaskById")
    public Object getCheckTaskById(Integer taskId){
        return zhouqiInfoService.getCheckTaskById(taskId);
    }

    @ResponseBody
    @PostMapping("/getGroupInfoById")
    public Object getGroupInfoById(Integer groupId){ return zhouqiInfoService.getGroupInfoById(groupId);}

    @ResponseBody
    @PostMapping("/getAllTask")
    public Object getAllTask(){
        return zhouqiInfoService.getAllTask();
    }

    @ResponseBody
    @PostMapping("/getInfoFromNewSystem")
    public Object getInfoFromNewSystem(Integer taskId,Integer preNum,Integer nodeDepth){
        return zhouqiInfoService.getInfoFromNewSystem(taskId,preNum,nodeDepth);
    }

    @ResponseBody
    @PostMapping("editNewSystemWeight")
    public Object editNewSystemWeight(String systemList){
        return zhouqiInfoService.editNewSystemWeight(systemList);
    }
}
